import yaml

class Dict(dict):
    __setattr__ = dict.__setitem__
    __getattr__ = dict.__getitem__

def dict2obj(dictObj):
    if not isinstance(dictObj, dict):
        return dictObj
    d = Dict()
    for k, v in dictObj.items():
        d[k] = dict2obj(v)
    return d

def load_yaml(yaml_file):
    with open(yaml_file, 'r', encoding="utf-8") as f:
        data = f.read()
    return yaml.load(data, Loader=yaml.SafeLoader)

def load_param(yaml_path):
    all_dict = load_yaml(yaml_path)
    cfg_dict = all_dict[all_dict['active']]
    args = dict2obj(cfg_dict)
    return args 
